#include<bits/stdc++.h>
using namespace std;
const int MAXN=100005;
int p[2000005];
bool vis[100005];
struct Node{
    int a,d;
    double v;
}cars1[MAXN],cars2[MAXN];
bool cmp(Node a,Node b){
    return a.d>b.d;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;cin>>t;
    for(int k=1;k<=t;k++){
        memset(vis,0,sizeof(vis));
        int n,m,l;double vm;
        cin>>n>>m>>l>>vm;
        int tot1=0,tot2=0;
        for(int i=1;i<=n;i++){
            int a1,a2,a3;
            cin>>a1>>a2>>a3;
            if(a3>=0)
                cars1[++tot1].d=a1,cars1[tot1].v=a2,cars1[tot1].a=a3;
            else
                cars2[++tot2].d=a1,cars2[tot2].v=a2,cars2[tot2].a=a3;
        }
        for(int i=1;i<=m;i++)
            cin>>p[i];
        int ans1=0,ans2=0;vis[p[m]]=1;
        sort(cars2+1,cars2+tot2+1,cmp);
        int l_dis=p[m],r_dis=p[m];
        for(int i=1;i<=tot2;i++){
                if(cars2[i].d>r_dis)
                    continue;
                int j=p[upper_bound(p+1,p+m+1,cars2[i].d)-p];
                double x=pow(cars2[i].v,2)+2*cars2[i].a*(j-cars2[i].d);
                if(x<=vm*vm)continue;
                ans1++;
                if(l_dis>j){
                    double y=pow(cars2[i].v,2)+2*cars2[i].a*(l_dis-cars2[i].d);
                    if(y<=vm*vm){
                        l_dis=j;
                        vis[j]=1;
                        ans2++;
                    }
                }
        }for(int i=1;i<=tot1;i++){
                if(cars1[i].d>r_dis)
                    continue;
                double x=pow(cars1[i].v,2)+2*cars1[i].a*(r_dis-cars1[i].d);
                if(x>vm*vm)
                    ans1++;
        }
        if(!ans2)
            ans2=1;
        cout<<ans1<<" "<<m-ans2<<endl;
    }
    return 0;
}
